from django.contrib import admin
from .models import Category, Book, Ads


# Register your models here.


@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
    list_display = ("__str__",)
    # list_display_links = ()


@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
    # 设置展示数据
    list_display = ("__str__", "category", "pub_date")
    # 设置超链接
    # list_display_links = ("category",)
    # 类别过滤器
    list_filter = ("category",)
    # 一页展示两个数据
    list_per_page = 2
    # 增加标题搜索框
    search_fields = ("title",)


@admin.register(Ads)
class AdsAdmin(admin.ModelAdmin):
    list_display = ("title", "url")
